package br.mg.bhe.ftpobre.util;

/**
 * 
 * @author Aureliano
 */
public final class FileSizeConverter {

	private FileSizeConverter() {
		super();
	}
		
	public static String convertFileSize(long size) {
		int baseKb = 1024;
		int baseMb = 1048576;
		int baseGb = 1073741824;
		
		if ((size >= 0) && (size < baseKb)) {
			return size + " Bytes";
		} else if ((size >= baseKb) && (size < baseMb)) {
			return (size / baseKb) + " KB";
		} else if ((size >= baseMb) && (size < baseGb)) {
			return (size / baseMb) + " MB";
		} else if (size >= baseGb) {
			return (size / baseGb) + " GB";
		} else {
			return String.valueOf(size);
		}
	}
}